<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="传图下单" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script src="/js/popup_ext.js"></script>
<script src="/js/jquery.js"></script>
<script src="/js/EkUpload.js"></script>
<script language="javascript">
	function doCancel(){
		parent.ClosePop();
	}
	function doStart(){
		var files=document.getElementById("fileName").files;
		if(files.length>0){
			var lowerFn=files[0].name.toLowerCase();
			if(!lowerFn.endWith(".zip") && !lowerFn.endWith(".rar")){
				ShowAlert('提示框','传图的文件必须是rar或者zip格式！',200,100);
			}else{
				document.getElementById("startButton").disabled=true;
				document.getElementById("pauseButton").disabled=false;
				
				//不给修改,否则upload后插入数据有可能有偏差
				document.getElementById("fileName").disabled=true;
				
				EkUpload.upload(
					files,
					function(msg){
						ShowAlert('提示框',msg,200,100);
					},
					null,
					showUploadProc,
					doUploadCallback
				);
			}
		}else{
			ShowAlert('提示框','请选择要上传的文件！',200,100);
		}
	}
	function showUploadProc(total,ci){
		var totalStr=parseFileSize(total);
		var ciStr=parseFileSize(ci);
		var percentStr;
		if(total!=0){
			percentStr=(Math.round(ci*100/total)).toString()+"%";
			if(percentStr!="0%"){
				document.getElementById("proTd").style.width=percentStr;
				document.getElementById("percentTd").innerHTML=percentStr;
				if(ci==total){//100%
					document.getElementById("remainTd").style.display="none";
				}else{
					document.getElementById("remainTd").style.display="";
				}
			}
		}
		document.getElementById("proSpan").innerHTML="已传"+ciStr+"，总文件大小"+totalStr;
	}
	function doUploadCallback(fileUrl){
		var fn=document.getElementById("fileName").files[0].name;
		var arr=fn.split("\\");
		var retArr=new Array();
		retArr[0]=arr[arr.length-1];
		retArr[1]=fileUrl;
		parent.popRetVal=retArr;
		parent.ClosePop();
	}
	function doPause(){
		if(document.getElementById("pause_flag").value==""){
			EkUpload.pause();
			document.getElementById("pause_flag").value="PAUSE";
			document.getElementById("pauseButton").value="继续";
		}else{
			EkUpload.restart();
			document.getElementById("pause_flag").value="";
			document.getElementById("pauseButton").value="暂停";
		}
	}
	
	function showMe(){
		if(checkNavigator()[0]!="msie"){
			document.getElementById("fileName").className="";
		}
	}
	function keepAlive(){
		var currentTime=new Date();
		var xmlHttp=createXMLHttpRequest();
		xmlHttp.open("GET", "/Foot.ihtm?random="+currentTime.getTime(),true);
		xmlHttp.send(null);
		setTimeout("keepAlive()",1000*60*10);
	}
</script>
</head>
<body oncontextmenu="return false" scroll="no" onLoad="showMe();keepAlive();" class="sheet modal-dialog" style=" padding-top:10px;">
<div class="sheet-main" style="width:530px;" id="bodyDiv">
  <div class="sheet-list" style="width:100%;">
    <div class="modal-main search-business">
    	<div style="width:100%;">
 			<c:set var="pageTopTitle" value="传图下单" />
			<%@ include file="../inc/PageTop.jsp"%>
			
			<div class="blank12"></div> 
			<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-0" >
				<tr>			   	
			      	<th style="width:20%">文件名称：</th>
			      	<td style="width:80%">
						<input type="file" name="fileName" id="fileName" style="width:220px" class="TextBox">
			     	</td>
				</tr>
				<tr>
			      	<th>进度：</th>
			      	<td>
						<table border="0" id="proTbl" class="table-c">
							<tr>
								<td style="width:84%;height:30px">
									<table height="20px" border="1" class="table-c">
										<tr>
											<td id="proTd" name="proTd" style="width:1px;" bgcolor="#3333cc"></td>
											<td id="remainTd" name="remainTd" bgcolor="#cccccc" style="width:100%">&nbsp;</td>
										</tr>
									</table>
								</td>
								<td id="percentTd" name="percentTd">0%</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
		      		<th>状态：</th>
					<td id="proSpan" name="proSpan">未上传</td>
				</tr>
			</table>
			
			<table border="0" cellspacing="2" cellpadding="2" align="center" class="table-c">
				<tr>
					<td align="right" class="give" style="width:42px;">说明：</td>
					<td class="give">1.上传的文件必须是zip或者rar的压缩文件，文件命名为客户名称</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td class="give">2.压缩文件中的图片，文件命名规则：项目类型-材质-内容-制作要求-宽X高X数量，系统根据文件名自动填写业务单</td>
				</tr>
			</table>
			</div>
		</div>
	</div>
	<div class="modal-buttom">
		<input type="button" class="buttom-a" value=" 上 传 " id="startButton" onClick="doStart();">
		<input type="button" class="buttom-a" value=" 暂 停 " id="pauseButton" onClick="doPause();" disabled="true">
		<input type="button" class="buttom-a" value=" 取 消 " onClick="doCancel();" >	
		<input type="hidden" id="pause_flag" value="">
	</div>
</div>
</body>
</html>